package com.example.module_maintenance.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.module_maintenance.R
import com.example.module_maintenance.entity.RepairEntity

class RepairAdapter : BaseQuickAdapter<RepairEntity,BaseViewHolder>(R.layout.item_repait){
    override fun convert(holder: BaseViewHolder, item: RepairEntity) {
        holder.setText(R.id.gongdanhao,"工单号:${item.orderNumber}")
        holder.setText(R.id.baoxiushijian,"保修时间:${item.repairTime}")
        holder.setText(R.id.baoxiuren,"报修人:${item.repairName}")
        holder.setText(R.id.weizhi,item.repairLocation)
        holder.setText(R.id.guzhang,"故障描述:${item.faultDescription}")
        holder.setText(R.id.dianhua,"联系电话:${item.contactMethod}")





        when (item.processingStatus) {
            "待处理" -> {
                holder.setText(R.id.item_visitor_management_status, "已完成")
                holder.setBackgroundResource(
                    R.id.item_visitor_management_status, R.drawable.shape_f9fafb_corners12
                )
                holder.getView<TextView>(R.id.item_visitor_management_status)
                    .setTextColor(Color.parseColor("#FFF59E0B"))
            }
            "处理中" -> {
                holder.setText(R.id.item_visitor_management_status, "处理中")
                holder.setBackgroundResource(
                    R.id.item_visitor_management_status, R.drawable.shape_f9fafb_corners13
                )
                holder.getView<TextView>(R.id.item_visitor_management_status)
                    .setTextColor(Color.parseColor("#FF028FF6"))
            }
            "待处理" -> {
                holder.setText(R.id.item_visitor_management_status, "待处理")
                holder.setBackgroundResource(
                    R.id.item_visitor_management_status, R.drawable.shape_f9fafb_corners14
                )
                holder.getView<TextView>(R.id.item_visitor_management_status)
                    .setTextColor(Color.parseColor("#FF84F18C"))
            }
        }
    }

}